﻿package com.amcharts.chartClasses
{
    import com.amcharts.axes.*;
    import com.amcharts.geom.*;
    import com.amcharts.utils.*;
    import mx.core.*;

    public class TrendLine extends UIComponent
    {
        public var lineAlpha:Number = 1;
        public var finalDate:Date;
        public var initialValue:Number;
        public var lineColor:Number = 13369344;
        public var initialDate:Date;
        public var finalCategory:String;
        public var dashLength:Number = 0;
        public var finalValue:Number;
        public var lineThickness:Number = 1;
        public var initialCategory:String;
        public var isProtected:Boolean;
        public var valueAxisX:ValueAxis;
        public var finalXValue:Number;
        public var valueAxis:ValueAxis;
        public var initialXValue:Number;
        public var categoryAxis:CategoryAxis;
        static const VERSION:String = "1.8.3.1";

        public function TrendLine()
        {
            return;
        }// end function

        public function destroy() : void
        {
            Utils.removeChildren(this);
            return;
        }// end function

        override protected function updateDisplayList(param1:Number, param2:Number) : void
        {
            var _loc_3:Number = NaN;
            var _loc_4:Number = NaN;
            var _loc_5:Number = NaN;
            var _loc_6:Number = NaN;
            var _loc_7:Line = null;
            super.updateDisplayList(param1, param2);
            destroy();
            if (categoryAxis)
            {
                if (initialDate)
                {
                    _loc_3 = categoryAxis.dateToCoordinate(initialDate);
                }
                if (initialCategory)
                {
                    _loc_3 = categoryAxis.categoryToCoordinate(initialCategory);
                }
                if (finalDate)
                {
                    _loc_4 = categoryAxis.dateToCoordinate(finalDate);
                }
                if (finalCategory)
                {
                    _loc_4 = categoryAxis.categoryToCoordinate(finalCategory);
                }
            }
            if (valueAxisX)
            {
                if (!valueAxis.recalculateToPercents)
                {
                    if (!isNaN(initialXValue))
                    {
                        _loc_3 = valueAxisX.getCoordinate(initialXValue);
                    }
                    if (!isNaN(finalXValue))
                    {
                        _loc_4 = valueAxisX.getCoordinate(finalXValue);
                    }
                }
            }
            if (valueAxis)
            {
                if (!valueAxis.recalculateToPercents)
                {
                    if (!isNaN(initialValue))
                    {
                        _loc_5 = valueAxis.getCoordinate(initialValue);
                    }
                    if (!isNaN(finalValue))
                    {
                        _loc_6 = valueAxis.getCoordinate(finalValue);
                    }
                }
            }
            if (!isNaN(_loc_3))
            {
            }
            if (!isNaN(_loc_4))
            {
            }
            if (!isNaN(_loc_5))
            {
            }
            if (!isNaN(_loc_5))
            {
                _loc_7 = new Line([_loc_3, _loc_4], [_loc_5, _loc_6], lineColor, lineAlpha, lineThickness, dashLength);
                this.addChild(_loc_7);
            }
            return;
        }// end function

    }
}
